package Controller;

import Model.Emp;
import Service.serviceImpl.EmpService;

import java.util.Scanner;

/**
 *  控制层，选择业务
 */
public class UserController {
    private static int empId = 1;
    public  static  int num=0;//数据元素的下标，所有类共享一份，所以直接用

    public void userServiceRequest() {

        Emp[] emp = new Emp[100]; //数据仓库
        boolean flag = true;
        while (flag) {
            System.out.println("**********请选择你要操作的业务***********");
            System.out.println("1.查询员工信息");
            System.out.println("2.添加员工信息");
            System.out.println("3.删除员工信息");
            System.out.println("4.退出");
            Scanner scanner = new Scanner(System.in);
            int menu = scanner.nextInt();
            switch (menu) {
                case 1:
                    System.out.println("1.查询员工信息");
                    break;
                case 2://业务

                    //生成一条员工信息
                    Emp user = new Emp();
                    user.setEmpId(UserController.empId++);
                    System.out.println("请输入员工的姓名");
                    String name = scanner.next();
                    user.setName(name);

                    System.out.println("请输入员工的性别");
                    String sex = scanner.next();
                    user.setSex(sex);

                    System.out.println("请输入员工的年龄");
                    Integer age = scanner.nextInt();
                    user.setAge(age);

                    System.out.println("请输入员工的职位");
                    String job = scanner.next();
                    user.setJob(job);

                    //控制层访问业务逻辑层
                    EmpService EmpService = new EmpService();
                    EmpService.addEmp(emp, user,num);
                    break;
                case 3:
                    System.out.println("3.删除员工信息");
                    break;
                case 4:
                    System.out.println("再见");
                    flag = false;
                    break;
            }
        }
    }
}
